<!DOCTYPE html>
<html>
<head>	
	<title>{:C('SERVER_HOME_NAME')}</title>

	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width">
	<link rel="stylesheet" type="text/css" href="__PUBLIC__/css/style.css" /> 		
	<link rel="stylesheet" href="__PUBLIC__/kindeditor/themes/default/default.css" />
	<link rel="stylesheet" href="__PUBLIC__/kindeditor/plugins/code/prettify.css" />
				

</head>
<style type="text/css">
	.package-choose{
		display: none;
	}
	.main table td{
		width: 40px;
	}
	.inputSearch input[type="button"]{
		width: 80px;
		height: 30px;
		font-size: 16px;
		line-height: 30px;

	}
	.inputSearch input[type="text"]{
		height: 30px;
		font-size: 16px;
	}
	.newsType{

		color:#000;

	}
	.industry input{
		line-height: 36px;
	    font-size: 20px;
	    padding-left: 20px;
	    margin-left: 10px;
	    outline: none;
	    width: 150px;

	}
	.industry span{
		
		font-size: 35px;
		margin-left: 10px;
		cursor:pointer
	}

</style>
<body>
	<div class="box">
		<include file="Public/top" />

		<div class="content">
			<include file="newsLeft" />
			<div class="main p30">
				<form action="__URL__/addNewsOrder.html" method="post" onSubmit="return beforeSubmit(this);" enctype="multipart/form-data"
>
					<table style="width:100%;">
						<tbody>
							<tr class="tbs-btn">
								<td>类型：</td>
								<td><span class="cur"><a class="newsType" href="newsRelease.html">自选投稿</a></span>
							</tr>

								<tr class="tbs-btn inputSearch">
									<td>搜索：</td>
									<td><input id="keyword"  type="text" placeholder="请输入查询关键词" ></td>
								</tr>

						
							<tr class="tbs-btn">
								<td>套餐：</td>
								<td>
									<div class="package">
										<div class="package-choose"><span class="cur">经济(100币发8站)</span><span>豪华(500币发10站)</span><span>旗舰<!-- (1000币发到门户网站) --></span>
										</div>
										<div class="package-main">
									
										
										<ul id="newsList">

													<volist name="comList" id="vo">
														<li data-id="{$vo.id}"><input type="checkbox">({$vo.news_name}) ({$vo.news_price})</li>
													
													</volist>	
										</ul>						
												
																					
										</div>
									</div>
								
								</td>
							</tr>
							<tr>
								<td>已选</td>
								<td>
									<div class="package-content">
										<p>总计：<span>0.00 </span></p>
										<input type="hidden" name="order_price">
										<ul class="package-box">
													
										</ul>
									</div>
								</td>
							</tr>
							<tr >
									<td >应用场景：</td>
									<td class="industry"><w><input name="industry[]"  type="text"  ></w><span class="add">+</span><span class="reduce">-</span></td>
							</tr>
							<tr>
								<td>标题：</td>
								<td class="subject"><span><input type="text" name="news_title" placeholder="请输入主题"></span></td>
							</tr>
							<tr>
								<td>内容：</td>
								<td><div id="page"><textarea id="kind" name="news_content" style="width:800px;height:400px;"></textarea></div></td>
							</tr>
						</tbody>		
					</table>
					<div class="btn-form"><input class="btn m400" type="submit" value="发布"><a href="#" class="btn m40">导入代写</a></div>
				</form>
			</div>
			
		</div>
	</div>
	<div class="layer-box">
		<div class="layer">
			<div class="shut fr"><img src="__PUBLIC__/images/close.png"></div>
			<div class="text"></div>
			<div class="btn"><a href="#" class="confirm">确定</a><a href="#" class="close">取消</a></div>	
		</div>

	</div>
	<script type="text/javascript" src="__PUBLIC__/js/jquery-1.7.min.js"></script>
	<script src="__PUBLIC__/js/page.js"></script>
	<script charset="utf-8" src="__PUBLIC__/kindeditor/kindeditor-all.js"></script>
	<script charset="utf-8" src="__PUBLIC__/kindeditor/lang/zh-CN.js"></script>
	<script charset="utf-8" src="__PUBLIC__/kindeditor/plugins/code/prettify.js"></script>
	<script>
		KindEditor.ready(function(K) {
			var editor1 = K.create('#kind', {
				cssPath : '__PUBLIC__/kindeditor/plugins/code/prettify.css',
				uploadJson : '__PUBLIC__/kindeditor/php/upload_json.php',
				fileManagerJson : '__PUBLIC__/kindeditor/php/file_manager_json.php',
				allowFileManager : true,
				afterCreate : function() {
					var self = this;
					K.ctrl(document, 13, function() {
						self.sync();
						K('form[name=example]')[0].submit();
					});
					K.ctrl(self.edit.doc, 13, function() {
						self.sync();
						K('form[name=example]')[0].submit();
					});
				}
			});
			prettyPrint();
		});
	</script>

	<script type="text/javascript">
	$(document).ready(function(){


			
            var maxPage = "{$totalPages}";
            var page = 1;
            
            $(".package-main").on("scroll", function () {
            	
            	var keyword =$("#keyword").val();
            	var $this =$(this),
		         viewH =$(this).height(),//可见高度
		         contentH =$(this).get(0).scrollHeight,//内容高度
		         scrollTop =$(this).scrollTop();//滚动高度

            	if(scrollTop/(contentH -viewH)>=0.95){


	            	 if ( page < maxPage) {
	            	 	$.get("__URL__/newsRelease", {page: page + 1,keyword:keyword}, function (data) {
	            	 	
	            	 	var str="";
	            	 	for (var i = 0; i < data.length; i++){

	            	 		str+="<li data-id='"+data[i]['id']+"' ><input type='checkbox'>("+data[i]['news_name']+") ("+data[i]['news_price']+")</li>"

	            	 	}
	            	 	str =$(str);
	            	 	$("#newsList").append(str);

	            	 	page++;	
	            	 	},"json");

	            	 }	
            	 }
            });

		});

		$("#keyword").bind("input propertychange",function(event) {
			var keyword=$(this).val();
			
				$.get("__URL__/newsRelease",{keyword:keyword},function(data){
						var str="";
	            	 	for (var i = 0; i < data.length; i++){

	            	 		str+="<li data-id='"+data[i]['id']+"' ><input type='checkbox'>("+data[i]['news_name']+") ("+data[i]['news_price']+")</li>"

	            	 	}
	            	 	str =$(str);
	            	 	$("#newsList").html(str);


					
				},"json");
			
		});
	
		$(".package-main").on("click", ":checkbox", function () {
			var _this=$(this);
			var data_id=_this.parent("li").attr("data-id");
			if ($(this).attr("checked")=="checked") {
				$(".package-box").append("<li data-id='"+data_id+"'><input name='news_ids[]' value='"+data_id+"' type=checkbox checked>"+$(this).parent().text()+"</li>");

				

			}else{			
				$(".package-box").find("li[data-id='"+data_id+"']").remove();
			}
			getTotolPrice();	
		});

		$(".package-box").on("click", ":checkbox", function (){
			var _this=$(this);
			var data_id=_this.parent("li").attr("data-id");
			_this.parent("li").remove();
			$(".package-main").find("li[data-id='"+data_id+"'] input").attr("checked",false);
			getTotolPrice();

		})


		function getTotolPrice(){

			var priceTotol=0;
				$(".package-box li").each(function(){

					var price=$(this).text().split('(');

						price=price[2].substring(0,price[2].length-1);	
					 priceTotol=priceTotol+parseInt(price);
				});
				$(".package-content span").text(priceTotol);
				$("input[name=order_price]").val(priceTotol);

		}

		$(".add").on("click",function(){
			
			$(".industry w").append('<input name="industry[]"  type="text"  >');
		});
		$(".reduce").on("click",function(){
			
			$(".industry w input").last().remove();
		});


	</script>		
</body>
</html>